import Vue from 'vue'
import VueRouter from 'vue-router'
// 同步导入
import HomePage from "../views/home/HomePage.vue"
import SignUp from "../views/sign/SignUp.vue"
import SignIn from "../views/sign/SignIn.vue"

Vue.use(VueRouter)

const routes = [
  {//首页
    path: '/',
    name: "home",
    alias: '/home',//别名
    component: HomePage
  },
  {//产品列表
    path: '/list/:type_one?',
    name: 'list',
    component: () => import('../views/list/ListPage.vue')
  },
  {//产品详情
    path: '/details',
    name: 'details',
    component: () => import('../views/details/DetailsPage.vue')
  },
  {//搜索结果
    path: '/search',
    name: 'search',
    component: () => import('../views/search/SearchPage.vue')
  },
  {//注册
    path: '/signup',
    name: 'signup',
    component: SignUp
  },
  {//登录
    path: '/signin',
    name: 'signin',
    component: SignIn
  },
  {//购物车
    path: '/cart',
    name: 'cart',
    component: () => import('../views/cart/CartPage.vue')
  }


]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes,
  scrollBehavior() {
    // 跳转路由后时钟从头开始
    return { x: 0, y: 0 }
  }
})

export default router
